﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using AppManagement.Repositories;
using AppManagement.Models;
using AppManagement.Helpers;
using AppManagement.BusManagers;

namespace AppManagement.Reports
{
    public partial class FrmBaoCaoDoanhSoTheoBacSy : Office2007Form
    {
        // Hidden files are used to store ids 
        private DevComponents.DotNetBar.Controls.TextBoxX txtMaBacSy;

        public FrmBaoCaoDoanhSoTheoBacSy()
        {
            InitializeComponent();
            InitHiddenFields();
        }

        /// <summary>
        /// Init hidden fields
        /// </summary>
        public void InitHiddenFields()
        {
            // Add a new textbox
            txtMaBacSy = new DevComponents.DotNetBar.Controls.TextBoxX
            {
                Name = "txtMaBacSy",
                Text = ""
            };
            txtMaBacSy.Visible = false;
        }

        private void btThoat_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btnBaoCao_Click(object sender, EventArgs e)
        {
            if (txtMaBacSy.Text == "")
            {
                MessageBoxEx.Show("Vui lòng chọn bác sỹ", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (dtTuNgay.Value == DateTime.MinValue)
            {
                MessageBoxEx.Show("Vui lòng chọn ngày bắt đầu", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (dtDenNgay.Value == DateTime.MinValue)
            {
                MessageBoxEx.Show("Vui lòng chọn ngày kết thúc", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            FrmInBaoCaoDoanhSoTheoBacSy frm = new FrmInBaoCaoDoanhSoTheoBacSy(txtMaBacSy.Text, dtTuNgay.Value, dtDenNgay.Value);
            frm.ShowDialog();
        }

        private void btnChonBacSy_Click(object sender, EventArgs e)
        {
            FrmQuanLyNhanVien frm = new FrmQuanLyNhanVien(true);
            frm.Handler += GetBacSy;
            frm.ShowDialog();
        }

        public void GetBacSy(object sender, EventArgs e)
        {
            var eventType = (TransferSimpleDataEvent)e;
            string[] comp = eventType.Data.Split(new char[] { '#' });

            txtMaBacSy.Text = comp[0];
            txtBacSy.Text = comp[1];
        }
    }
}
